package com.xesj.serviceimpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.xesj.dao.RoleMapper;
import com.xesj.model.Role;
import com.xesj.service.RoleServiceI;
import com.xesj.util.PageData;

@Service("roleService")
@Transactional
public class RoleServiceImpl implements RoleServiceI {
	@Autowired
	private RoleMapper roleDao;
	@Override
	public List<PageData> allRoleListByName(PageData pd) {
		
		return roleDao.allRoleListByName(pd);
	}
	@Override
	public int updateRole(Role role) {
		// TODO Auto-generated method stub
		return roleDao.updateRole(role);
	}
	@Override
	public int givePermission(String[] permissionIds, String roleId) {
		// TODO Auto-generated method stub
		int count = 1;
		for (String permissionId : permissionIds) {
			count = roleDao.givePermission(roleId,permissionId);
			if (count==0) {
				return count;
			}
		}
		return count;
	}

}
